<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>单元格内容水平对齐</title>
</head>

<body>
    <table width="100%" border="1">
        <tr id="header">
            <th>Firstname</th>
            <th>Lastname</th>
        </tr>
        <tr>
            <td>Peter</td>
            <td>Griffin</td>
        </tr>
    </table>
    <br>
    <input type="button" onclick="leftAlign()" value="内容向右对齐" />
    <p><b>注意:</b>该实例不适用IE浏览器。</p>
    <script>
        function leftAlign() {
            document.getElementById('header').align = "left";
        }
    </script>
</body>

</html>